<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
/*
	支付日志
*/
defined('BY_JYA') or exit('error');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$return['statuss']=array(
	'0'=>'待支付',
	'1'=>'已支付',
	'2'=>'支付失败'
);
$return['statuss2']=array(
	array('id'=>0,'title'=>'待支付'),
	array('id'=>1,'title'=>'已支付'),
	array('id'=>2,'title'=>'支付失败')
);
$return['pay_types']=array(
	'wechat'=>'微信支付',
	'wxapp'=>'小程序支付',
	'alipay'=>'支付宝支付',
	'ttpay'=>'头条支付',
	'yinlian'=>'银联支付',
	'credit'=>'余额支付'
);
$return['pay_types2']=array(
	array('id'=>'wechat','title'=>'微信支付'),
	array('id'=>'wxapp','title'=>'小程序支付'),
	array('id'=>'alipay','title'=>'支付宝支付'),
	array('id'=>'ttpay','title'=>'头条支付'),
	array('id'=>'yinlian','title'=>'银联支付'),
	array('id'=>'credit','title'=>'余额支付'),
);
if($_RQ['op']=='main'){
	$return['params']=array('ispiao'=>intval($_RQ['ispiao']));
	$return['isfee']=pdo_getsum('core_paylog',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>1,'ispiao'=>1),'fee');
	$return['nofee']=pdo_getsum('core_paylog',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>1,'ispiao'=>0),'fee');
	$return['list']=array();
	$return['backurl']=$_SESSION['backurl']?:'jy_invoice/member.index/';
	exi($return);
}
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = $_RQ['psize']?:10;
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>1,'ispiao'=>intval($_RQ['ispiao']));
	//会员ID
	if(!empty($_RQ['mid'])){
		$params['mid']=intval($_RQ['mid']);
		$return['params']['mid']=$_RQ['mid'];
	}
	if(!empty($_RQ['tid'])){
		$params['tid']=$_RQ['tid'];
		$return['params']['tid']=$_RQ['tid'];
	}
	//支付方式
	if(!empty($_RQ['pay_type'])){
		$params['pay_type']=trim($_RQ['pay_type']);
		$return['params']['pay_type']=$_RQ['pay_type'];
	}
	if($_RQ['createtime']){
		$time_range=cfc('tools')->base64_decode($_RQ['createtime'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$return['params']['createtime']=$time_range;
		$params['createtime between']=array($time_range['tstart'],$time_range['tend']);
	}
	$fields=array('id','mid','tid','oid','status','pay_type','createtime','fee','di_fee','plugin','title','ispiao');
	$list=pdo_getslice('core_paylog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($list as &$item){
		$item['statustitle']=$return['statuss'][$item['status']];
		$item['pay_typetitle']=$return['pay_types'][$item['pay_type']];
		$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
		$item['piaotime']=$item['piaotime']?date('Y-m-d',$item['piaotime']):'';
	}
	$return['list']=$list?$list:array();
	exi($return);
}